package com.xhhospital.servlet;

import com.xhhospital.dao.BrxxDao;
import com.xhhospital.entity.Brxx;

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "SaveBrxxServlet",urlPatterns = "/saveBrxx")
public class SaveBrxxServlet extends HttpServlet {
            protected void doPost(HttpServletRequest request, HttpServletResponse response) {
                try {
                    request.setCharacterEncoding("utf-8");
                    response.setCharacterEncoding("utf-8");
                    response.setContentType("text/html;charset=utf-8");
                    PrintWriter out = response.getWriter();
                    out.println("<html><body>");
                    //获取参数
//                    String jzkh1=request.getParameter("jzkh");
//                    int jzkh=Integer.parseInt(jzkh1);
                    String blbh=request.getParameter("blbh");
                    String brxm=request.getParameter("brxm");
                    String brxb=request.getParameter("brxb");
                    String ysbh=request.getParameter("ysbh");
                    String ysxm=request.getParameter("ysxm");
                    String yszc=request.getParameter("yszc");
                    String ypmc=request.getParameter("ypmc");
                    String ypgg=request.getParameter("ypgg");
                    String ypsl=request.getParameter("ypsl");
                    String zdjg=request.getParameter("zdjg");
                    String zlff=request.getParameter("zlff");
                    String jzks=request.getParameter("jzks");
                    String zdsj=request.getParameter("zdsj");
                    //实体类
                    Brxx brxx = new Brxx();
//                    brxx.setJzkh(jzkh);
                    brxx.setBlbh(blbh);
                    brxx.setBrxm(brxm);
                    brxx.setBrxb(brxb);
                    brxx.setYsbh(ysbh);
                    brxx.setYsxm(ysxm);
                    brxx.setYszc(yszc);
                    brxx.setYpmc(ypmc);
                    brxx.setYpgg(ypgg);
                    brxx.setYpsl(ypsl);
                    brxx.setZdjg(zdjg);
                    brxx.setZlff(zlff);
                    brxx.setJzks(jzks);
                    brxx.setZdsj(zdsj);
                    //实现保存新增数据
                    int bool = BrxxDao.addBrxx(brxx);
                    if (bool > 0) {
                        out.print("数据新增成功");
                    } else {
                        out.print("数据新增失败");
                    }
                    out.close();
                }catch (Exception e){
                    e.printStackTrace();
                }
            }


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
